package reflect;

import java.lang.reflect.Method;

/**
 * 通过反射机制访问注解的参数
 */
public class ReflectDemo10 {
    public static void main(String[] args) {
        try {
            Class cls = Class.forName("reflect.Person");
            Method method = cls.getDeclaredMethod("sayHi");
            if (method.isAnnotationPresent(AutoRunMethod.class)){
                AutoRunMethod arm = method.getAnnotation(AutoRunMethod.class);
                int value = arm.value();
                System.out.println("注解的value属性的值是："+value);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
